Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update profilePage to include timezone #1717

Merged
merged 15 commits into from
Mar 19, 2021

Conversation

NikkiWines
Copy link
Contributor

@NikkiWines NikkiWines commented Mar 11, 2021

Details

PR does a couple of things:

  • Removes the now unnecessary fetchTimezone() function and updates the personalDetailsonyx key so that each user's personalDetails also contains a timezone.
  • Updates the priorityMode onyx key to comply with how we want to save NVP onyx keys.
  • Updates the selectable area for opening the details page to be the avatar and the user's name (as requested here
  • Updates the Details page so that it now includes an abbreviated timezone name for clarity (ex. 10:51 AM PST instead of just 10:51 AM)

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/156248

Tests

For testing you're going to need two accounts:
Account A: This an account who on a policy with multiple different users
Account B: Someone who is on the same policy as account A.

  1. Log into E.com with Account A
  2. Navigate to Settings > Account > Preferences > Timezone and modify your timezone
  3. Log into E.cash with Account A and check your myPersonalDetails onyx key to confirm it contains the correct timezone.
  4. In E.cash, send a message to Account B
  5. Confirm the message has the correct timestamp for your timezone.
  6. Click on the name of Account B in the chat header (not on the avatar) and confirm it opens up the Details page.
  7. Confirm you see Account B's timezone in the details.
  8. In E.cash, navigate to Settings > Preferences and confirm the page loads as expected
  9. Confirm you can modify your priority mode selection and that the nvp_priorityMode onyx key updates correctly.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Screen Shot 2021-03-19 at 10 00 04 AM

Mobile Web

Desktop

Screen Shot 2021-03-19 at 10 26 03 AM

iOS

Android

Video of Clicking on Chat Header

Screen.Recording.2021-03-19.at.10.20.12.AM.mov

…e from personalDetailsList not separate API call
@NikkiWines NikkiWines self-assigned this Mar 11, 2021
@NikkiWines NikkiWines changed the title Add timezone to personalDetails key Rename DetailsPage and update it to include timezone Mar 19, 2021
@NikkiWines NikkiWines changed the title Rename DetailsPage and update it to include timezone Update profilePage to include timezone Mar 19, 2021
@NikkiWines NikkiWines requested a review from a team March 19, 2021 17:33
@NikkiWines NikkiWines marked this pull request as ready for review March 19, 2021 17:33
@botify botify requested review from jasperhuangg and removed request for a team March 19, 2021 17:33
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good! I just have a few questions about the set/merge changes.

src/ONYXKEYS.js Show resolved Hide resolved
@@ -125,7 +112,7 @@ function fetch() {
})
.then((data) => {
const allPersonalDetails = formatPersonalDetails(data.personalDetailsList);
Onyx.merge(ONYXKEYS.PERSONAL_DETAILS, allPersonalDetails);
Onyx.set(ONYXKEYS.PERSONAL_DETAILS, allPersonalDetails);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change from merge() to set()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there may be some personal details created that are not in the personalDetailsList e.g. those added when loading reports or creating a chat with a brand new user. Is there a chance we are overwriting those here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we needed to merge otherwise I believe we'd overwrite the timeZone that was added to the personalDetails when we called fetchTimezone() but now the details returned from personalDetailsList and PersonalDetails_GetForEmails both contain the timeZone so there's no need to merge instead of set.

Is there a chance we are overwriting those here?

I suppose if we're getting different persoanlDetaials from the report, then yes we would be overwriting it, so it may be best to stick with merge over set in the end.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool. I think that's probably a safe bet here. It sort of makes sense to favor using merge() over set() unless there is a specific reason why we might want to blow away everything else we've got.

@@ -135,7 +122,7 @@ function fetch() {
myPersonalDetails.lastName = lodashGet(data.personalDetailsList, [currentUserEmail, 'lastName'], '');

// Set my personal details so they can be easily accessed and subscribed to on their own key
Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, myPersonalDetails);
Onyx.set(ONYXKEYS.MY_PERSONAL_DETAILS, myPersonalDetails);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question about why set and not merge. But I can't think of any place we are modifying the myPersonalDetails I think probably after the timezone changes in this PR we are just always overwriting the details with those from the server on page refresh. Which seems fine?

@marcaaron
Copy link
Contributor

Can't seem to get the timezone stuff to work (even after updating Auth). I don't have a great idea about why that would be but here's what I tried:

  • Clean make on Auth then make again
  • Change timezone for someone in e.com
  • Refresh page in e.cash and look at that guy's profile page
  • Timezone is still wrong

Screen Shot 2021-03-19 at 9 21 28 AM
Screen Shot 2021-03-19 at 9 21 57 AM

logged out response of personalDetailsList and a lot of stuff is just empty

Screen Shot 2021-03-19 at 9 39 32 AM

Any ideas?

@NikkiWines
Copy link
Contributor Author

Hmm, I'm not able to reproduce that issue.

Pre changes:
Screen Shot 2021-03-19 at 1 31 04 PM
Screen Shot 2021-03-19 at 1 30 41 PM

Post changes:

Screen Shot 2021-03-19 at 1 31 19 PM

@marcaaron
Copy link
Contributor

Ok after some back and forth @NikkiWines figured out that I must be testing with an account that did not have a personalDetails nvp set. We don't create one until the user modifies their avatar or name.

Maybe we can create a follow up issue to do something about that since it's a little confusing that we aren't picking up the tz in E.cash unless the user has modified some unrelated field first.

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests good!

add priorityMode migration
@NikkiWines NikkiWines requested a review from a team as a code owner March 19, 2021 21:09
@botify botify requested review from flodnv and removed request for a team March 19, 2021 21:09
@NikkiWines
Copy link
Contributor Author

updated!

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NikkiWines NikkiWines removed the request for review from flodnv March 19, 2021 22:05
@NikkiWines
Copy link
Contributor Author

Oops, my bad forgot that part.

@NikkiWines
Copy link
Contributor Author

updated!

@NikkiWines
Copy link
Contributor Author

updated once more with conflicts resolved.

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great !


Onyx.multiSet({
priorityMode: null,
[ONYXKEYS.NVP_PRIORITY_MODE]: oldPriorityMode,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda of unrelated but random thought here is that we should probably not reference ONYXKEYS in migration files since the migration is "forever" even tho the constant in Onyx could possibly change. Nothing to do here just a weird thought I guess.

@NikkiWines NikkiWines merged commit 56b4a96 into master Mar 19, 2021
@NikkiWines NikkiWines deleted the nikki-personaldetails-timezone branch March 19, 2021 23:35
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants